< previous page page_132 next page >

Page 132
z0152-01.gif
Figure 4.10
The geometry of rotated text.
The figure shows a rotated string with its bounding box and the internal leading space above the characters. You can learn the string's height without the internal leading space (H1) and total height (H2) using the GetTextMetrics API function described earlier in this chapter. The TextWidth function correctly returns the string's width (W).
The text has been rotated through the angle q. The angle f is 90 degrees minus q. Trigonometry gives the other distances marked on the figure.
Example program CentText, shown in Figure 4.11, uses the geometry shown in Figure 4.10 to display text centered in a picture box.
The heart of the program is the CenterText subroutine. CenterText takes as parameters the string to draw, the picture box to hold it, the coordinates where the string should be centered, and parameters describing the font the routine should use.
0132-02.jpg
Figure 4.11
Example program CentText displays rotated text centered in a picture box.

 
< previous page page_132 next page >